package com.ys.controller.api.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.sys.TsOrganizationInfo;
import com.ys.entity.sys.TsUserInfo;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.LayuiTableVoJA;

@Controller
@RequestMapping("/api/inter/tsUserInfoForAuthOrg")
public class ApiInterTsUserInfoForAuthOrgController {
	
//	private static final Logger logger = Logger.getLogger(ApiAdminLoginController.class);
	
	@Autowired
	private CommonApiService<TsUserInfo> commonApiService;

//	@RequiresPermissions("tsUserInfo:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute TsUserInfo cond,
			String guidTsOrganizationInfo
			){
		
		if (guidTsOrganizationInfo != null) {
			TsOrganizationInfo tsOrganizationInfo = new TsOrganizationInfo().setGuid(guidTsOrganizationInfo).queryFirst();
			cond.addRightJoin("YS_UserOrg AA on AA.UserId = A.UserId")
				.where("AA.orgId = '" + tsOrganizationInfo.getOrgid() + "'");
		}
		
		cond.setOrderby("A.UserId asc");
		
		
		return commonApiService.searchLay(cond);
	}
	
}
